package com.rainng.coursesystem.controller.admin;

import com.rainng.coursesystem.config.themis.annotation.Admin;
import com.rainng.coursesystem.controller.BaseController;
import com.rainng.coursesystem.model.entity.MemberEventEntity;
import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.service.admin.MemberEventService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Admin(Admin.MEMBER_EVENT_MANAGE)
@RequestMapping("/admin/member/event")
@RestController
public class MemberEventController extends BaseController {
    private final MemberEventService service;

    public MemberEventController(MemberEventService service) {
        this.service = service;
    }

    @GetMapping("/{id}")
    public ResultVO get(@PathVariable Integer id) {
        return service.get(id);
    }

    @PostMapping
    public ResultVO create(@RequestBody @Validated MemberEventEntity entity) {
        return service.create(entity);
    }

    @DeleteMapping("/{id}")
    public ResultVO delete(@PathVariable Integer id) {
        return service.delete(id);
    }

    @PutMapping
    public ResultVO update(@RequestBody @Validated MemberEventEntity entity) {
        return service.update(entity);
    }

    @RequestMapping("/page/count")
    public ResultVO getPageCount(String teamName, String eventName, String memberName) {
        return service.getPageCount(teamName, eventName, memberName);
    }

    @RequestMapping("/page")
    public ResultVO getPage(String teamName, String eventName, String memberName) {
        return service.getPage(1, teamName, eventName, memberName);
    }

    @RequestMapping("/page/{index}")
    public ResultVO getPage(@PathVariable Integer index, String teamName, String eventName, String memberName) {
        return service.getPage(index, teamName, eventName, memberName);
    }
}
